@import 'layout_variables';
@import '_variables';

body.caerp {
	&[class*="preview-view"] {
		img.wtmk {
			height: auto;
			max-height: 100vh;
			opacity: .33;
			pointer-events: none;
			position: absolute;
			top: 0;
			width: 100%;
			z-index: 2;
		}
	}

	.task_header {
		margin: var(--padding-s);

		.full_banner {
			height: auto;
			max-width: 100%;
		}

		.pdf_logo {
			border: 0 none $print_background;
			width: auto;

			tr {
				background: none !important;
			}

			td {
				border: 0 none $print_background;
				text-align: left;
				vertical-align: middle;

				&.logo_cell {
					height: 140px;
					overflow: hidden;
					width: 140px;
				}
			}

			.logo_img {
				height: auto;
				width: 128px;
			}
		}

		.pdf_address_block {
			display: flex;
			justify-content: flex-end;

			>div {
				background: $print_transWhite;
				display: inline-block;
				margin-right: 3em;
				position: relative;
				width: 23em;
				padding: var(--padding-3xl);

				.corner {
					border: 1px dotted $print_lightGrey;
					height: 2em;
					display: block;
					position: absolute;
					width: 2em;

					&.bottom {
						border-top-width: 0;
						bottom: 0;
					}

					&.left {
						border-right-width: 0;
						left: 0;
					}

					&.right {
						border-left-width: 0;
						right: 0;
					}

					&.top {
						border-bottom-width: 0;
						top: 0;
					}
				}
			}
		}
	}

	.task_view {
		background: $print_background;
		color: $print_text;

		&.tab_preview {
			box-shadow: none;
			position: relative;

			img.wtmk {
				height: auto;
				max-height: 100%;
				opacity: .33;
				pointer-events: none;
				position: absolute;
				top: 0;
				width: 100%;
				z-index: 2;
			}
		}

		>div {
			margin: var(--padding-s);

			.pdf_mention_block {
				margin-left: 0;
				margin-right: 0;
			}
		}

		.pdf_information {
			font-size: .875em;

			h1 {
				font-size: 1.25rem;
				padding: var(--padding-s) 0;
			}

			.coop_header {
				background: $print_transWhite;
				border: 3px solid $print_fadedGrey;
				margin-top: var(--padding-s);
				padding: var(--padding-s);
			}

			.info_cols {
				align-items: flex-end;
				display: flex;
				justify-content: space-between;
				padding-bottom: 15px;

				.customer_info {
					flex: 0 0 calc(26rem - 30px);
					margin-left: var(--padding-s);
					padding-top: .75em;
				}
			}
		}

		.pdf_mention_block {
			background: $print_transWhite;
			border: 3px solid $print_fadedGrey;
			margin: var(--padding-l) var(--padding-s) 0;

			h4 {
				background: $print_fadedGrey;
				border: none;
				color: $print_text;
				padding: 0 var(--padding-s) var(--padding-xs);
			}

			p {
				font-size: .875rem;
				padding: var(--padding-s);
			}

			th[scope="col"] {
				height: inherit;
			}
		}

		.document_help {
			font-size: .75rem;
		}

		.notes_group {
			display: flex;
			flex-wrap: wrap;
			justify-content: stretch;

			>div {
				flex: 1 1 calc(50% - 5px);

				&.options {
					display: flex;
					flex-direction: column;
					justify-content: center;
				}

				+div:nth-child(2n) {
					margin-left: var(--padding-s);
				}
			}
		}

		.payment_conditions {
			>div {
				align-items: flex-start;
				display: flex;
				justify-content: space-between;
				padding: var(--padding-s);

				p,
				>div {
					flex: 0 0 50%;
				}

				p {
					padding: 0 var(--padding-s) 0 0;
				}

				>div {
					padding-left: var(--padding-s);
				}
			}
		}

		.estimation_last_mention {
			align-items: flex-start;
			display: flex;
			justify-content: space-between;
			margin: 0 var(--padding-s);

			.pdf_mention_block {
				flex: 0 0 calc(100% - 19em);
			}

			.pdf_sign_block {
				margin: var(--padding-l) 0 0;
				flex: 0 0 18em;

				>div {
					border: 3px solid $print_fadedGrey;
					width: 18em;

					h4 {
						background: $print_fadedGrey;
						padding: 0 var(--padding-s) var(--padding-xs);
					}

					p {
						padding: var(--padding-m);
					}

					.signature {
						height: 6em;
					}
				}
			}
		}

		.pdf_task_table {
			margin-bottom: var(--padding-xl);
			margin-top: var(--padding-m);

			+.pdf_task_table {
				margin-top: var(--negative-padding-m);
			}

			h1 {
				background: none;
				color: $print_text;
			}

			table {
				border-width: 0;

				&:first-child {
					border-top-width: 2px;
				}

				&:last-child {
					border-bottom-width: 2px;
				}

				.group_description {
					.col_text {
						padding-bottom: var(--padding-m);
					}

					h2 {
						font-size: 1.125rem;
					}

					td {
						border-top-width: 2px;
					}

					p {
						margin: 0;
						padding: 0;
					}
				}

				.work_item td {
					border-top-style: dashed;

					&:first-child {
						padding-left: var(--padding-xl);
					}
				}

				.table_head th,
				.table_head td {
					color: $print_deepGrey;
				}
			}
		}

		.pdf_spacer {
			display: none;
		}

		table {
			background: $print_transWhite;
			border-collapse: collapse;
			border: 1px solid $print_fadedBorder;
			border-width: 2px 0;
			width: 100%;

			+table {
				border-top-width: 0;
				margin-top: -1px;
			}

			tbody,
			thead,
			tfoot {

				th,
				td {
					background: none;
					border: 1px solid $print_fadedBorder;
					border-width: 1px 0 0;
					padding: 4px;
				}

				th {
					vertical-align: bottom;
				}

				th[scope="col"] {
					border-top-width: 0;
					line-height: 1;
				}

				td {
					vertical-align: top;

					&.empty {
						padding: 0;
					}
				}

				td.empty {
					border-width: 0;
				}

				tr:nth-child(2n+1) {
					background: none !important;
				}

				td.archive {
					color: $print_darkGrey;
					font-style: italic;
				}

				tr.long_description {
					td {
						border-width: 0;
						padding: 0 4px 4px;
					}
				}

				tr.row_total {
					th,
					td {
						font-weight: bold;
					}
				}
			}

			tbody tr:not(:first-child) th.progress_invoicing {
				border-top-width: 0;
			}

			.col_text {
				hyphens: auto;
				text-align: left;

				&.description {
					overflow-wrap: anywhere;

					h1,
					h2,
					h3,
					h4,
					h5,
					h6 {
						font-weight: bold;
						margin: 0;
						padding: 0 0 var(--padding-s);
					}

					h1 {
						font-size: 1.25rem;
						line-height: 1rem;
					}

					h2 {
						font-size: 1.125rem;
						line-height: 1rem;
					}

					h3,
					h4,
					h5,
					h6 {
						font-size: 1rem;
					}
				}

				&.unity {
					overflow-wrap: break-word;
					width: 5em;
				}

				&.align_right {
					text-align: right;
				}

				&.rich_text ul {
					list-style-position: outside;
					margin-left: var(--padding-xl);

					li:first-child {
						padding-top: 4px;
					}

					li:last-child {
						padding-bottom: 0;
					}
				}
			}

			tr.work_description {
				h3.work_title {
					padding: 0;

					+* {
						padding-top: var(--padding-s);
					}
				}

				.col_number,
				.col_text.unity {
					font-weight: bold;
				}
			}

			.col_date {
				width: 8em;
			}

			.price,
			.price_total {
				width: 6em;
			}

			.progress_invoicing {
				text-align: center;
				width: 4em;
			}

			.deposit {
				width: 5.5em;
			}

			.price_total {
				background: $print_veryFadedGrey;
			}

			.quantity {
				width: 3em;
			}

			.tva {
				width: 4em;
			}
		}

		.cgv-container {
			border-top: 1px dashed var(--border-color);
			margin-top: var(--padding-xl);
		}
	}

	.pdf_footer {
		background: $print_veryFadedGrey;
		font-size: .75rem;
		margin: var(--padding-xl) var(--negative-padding-s) var(--padding-s);
		padding: var(--padding-s) var(--padding-s) 0;
		text-align: center;

		h4 {
			font-size: .75rem;
			padding-top: var(--padding-m);
		}

		p:last-child {
			padding-bottom: var(--padding-s);
		}
	}

	.pdf_page_number {
		font-size: .875rem;
		text-align: center;

		.page_count {
			display: none;
		}
	}

	.cgv-container {
		border-top: 1px dashed $print_midFadedGrey;
		margin: var(--padding-3xl) 0 var(--padding-s);
	}

	.pdf_cgv {
		font-size: .75rem;
		padding: var(--padding-xl) var(--padding-s);
		text-align: justify;
	}

	/* Attestation SAP */
	.sap_group {
		border-bottom-width: 0;
	}

	.sap_month {
		width: 12em;
	}

	.sap_label {
		width: 18em;
	}

	.sap_bottom_mention,
	.sap_bottom_signature {
		width: 50%;
	}

	.sap_bottom_signature {
		text-align: right;

		img {
			max-width: 12rem;
			max-height: 12rem;
		}
	}

}

body.caerp.caerp_popup {
	&[class*="preview-view"] {
		.main_area {
			padding: 5px;
		}
	}

	.pdf_footer {
		margin: var(--padding-s) 0;
	}

	.pdf_cgv {
		padding: var(--padding-xl) var(--padding-m);
	}
}

@media (max-width: $tabletWidth ) {
	body.caerp .tab-content {
		.layout.two_cols {
			>* {
				width: 100%;
			}

			>div {
				padding-left: 0;
				padding-right: 0;
			}
		}

		.task_view.tab_preview {
			overflow-x: auto;

			>* {
				min-width: 52em;
			}
		}
	}
}

body.caerp.pdf_export {
	html {
		font-size: $print_fontsize;
	}
}